package pers.gxm.observer;

public class DigitObserver implements Observer{
    public static void main(String[] args) {
        RandomNumberGenerator numberGenerator = new RandomNumberGenerator();
        numberGenerator.addObserver(new DigitObserver());
        numberGenerator.addObserver(new GraphObserver());
        numberGenerator.execute();

    }
    @Override
    public void update(NumberGenerator numberGenerator) {
        System.out.println("DigitObserver:" +  numberGenerator.getNumber());
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
//        没加线程试一下
    }
}
